<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>系统安全设置</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../layui/layui.js"></script>
    <style>
        .layui-form-item .layui-inline {
            padding-right: 0px;
            margin-right: 0px;
        }

        html,
        body {
            background-color: #fff;
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
            border: 0px;
        }
    </style>
</head>
<body layadmin-themealias="default">
<div class="layui-card" style="height: 100%">
    <div class="layui-card-header font20">
        <div class="layui-title">系统安全设置</div>
    </div>
    <div class="layui-card-body">
        <th:block th:if="${data.isExamine =='1'}">
            <blockquote class="layui-elem-quote layui-border-red">
                <i class="layui-icon layui-icon-about"></i> 设置正在审批中...
            </blockquote>
        </th:block>
        <div class="layui-panel">
            <form class="layui-form" lay-filter="postData" action="" id="postData">
                <input type="hidden" name="id" value="put" th:value="${data.id}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">三员分管</label>
                    <div class="layui-input-block" style="width: 220px">
                        <input type="checkbox" name="psRbac" title="开启|关闭" lay-skin="switch"
                               th:value="1" th:checked="${data.psRbac =='1'}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">固定IP</label>
                    <div class="layui-input-block" style="width: 220px">
                        <input type="checkbox" name="psFixedIp" title="开启|关闭" lay-skin="switch"
                               th:value="1" th:checked="${data.psFixedIp =='1'}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btn-sm layui-bg-blue" lay-submit=""
                                lay-filter="postData" id="postBut">
                            <i class="layui-icon layui-icon-ok"></i> 确定
                        </button>
                    </div>

                </div>

            </form>
        </div>
        <div class="layui-panel">
            <form class="layui-form" lay-filter="postData" action="" >
                <input type="hidden" name="id" value="put" th:value="${data.id}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">自动备份</label>
                    <div class="layui-input-block" style="width: 220px">
                        <input type="checkbox" name="psRbac" title="开启|关闭" lay-skin="switch"
                               th:value="1" th:checked="${data.psRbac =='1'}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备份间隔天数</label>
                    <div class="layui-input-block" style="width: 220px">
                        <input type="text" name="username" placeholder="请输入用户名称"
                               autocomplete="off" class="layui-input" required lay-verify="required" th:value="30"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btn-sm layui-bg-blue" lay-submit=""
                                lay-filter="postData" id="postBut">
                            <i class="layui-icon layui-icon-ok"></i> 确定
                        </button>
                    </div>

                </div>
        </div>
    </div>
</div>
<script>
    var callBackReturn = false;
    var index = parent.layer.getFrameIndex(window.name);
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();

        form.on('submit(postData)', function (obj) {
            var data = obj.field;
            if (data['psRbac'] == undefined) {
                data['psRbac'] = '0';
            }
            if (data['psFixedIp'] == undefined) {
                data['psFixedIp'] = '0';
            }
            $.ajax({
                url: './saveSecuritySetup', //url
                dataType: 'json', //数据格式
                contentType: 'application/json',
                type: 'POST', //请求方式
                async: false, //是否异步请求
                data: JSON.stringify(data),
                success: function (result) {
                    if (result.code == 0) {
                        parent.layer.msg(result.message, {icon: 1});
                        callBackReturn = true;
                        parent.layer.close(index);
                    } else {
                        parent.layer.alert(result.message, {icon: 2});
                    }
                },
            });
            return false;
        });
    });


    function Submit() {
        document.getElementById('postBut').click();
        return callBackReturn;
    }
</script>
<script type="text/javascript" src="../js/lib/watermark.js"></script>
</body>
</html>